class BubbleSort:
    def __init__(self, list_target):
        self.__list = list_target

    def sort(self):
        for i in range(len(self.__list) - 1):
            for j in range(len(self.__list) - i - 1):
                # 如果前一个数比后面一个数大则交换位置
                if self.__list[j] > self.__list[j + 1]:
                    self.__list[j], self.__list[j + 1] = self.__list[j + 1], self.__list[j]

    def print(self):
        for item in self.__list:
            print(item, end=' ')
        print()


if __name__ == '__main__':
    bubble_sort = BubbleSort([43, 4, 5, 2, 42, 89, 32, 67, 96])
    bubble_sort.sort()
    bubble_sort.print()
